package com.tencent.qcloud.tim.uikit;

import java.util.ArrayList;

/**
 * 创建者 zx
 * 创建时间 2020/12/22 15:57
 */
public class UnReadManager {
    private final String TAG = "UnReadManager";
    public final static int TYPE_CHECK = 1;//未审核
    public final static int TYPE_MSG = 2; //消息未读
    public final static int TYPE_REPORT = 3;//举报未读
    public final static int TYPE_SYS = 4;//系统消息未读
    public final static int TYPE_TASK = 5;//任务消息未读

    private static UnReadManager instance;

    public static UnReadManager getInstance() {
        if (instance == null) {
            instance = new UnReadManager();
        }
        return instance;
    }


    private int unreadCheck; //未审核
    private int unreadMsg; //消息未读
    private int unreadReport; //举报未读
    private int unreadTask; //任务未读
    private int unreadSys; //系统消息未读
    private ArrayList<Observer<Integer>> observers;

    private UnReadManager() {
        observers = new ArrayList<>();
    }

    public void register(Observer<Integer> observer) {
        observers.add(observer);
    }

    public void unregister(Observer<Integer> observer) {
        observers.remove(observer);
    }

    public int getUncheck() {
        return unreadCheck;
    }

    public void setUncheck(int uncheck) {
        this.unreadCheck = uncheck;
        for (Observer<Integer> o : observers
        ) {
            o.update(TYPE_CHECK, uncheck);
        }
    }

    public int getUnreadMsg() {
        return unreadMsg;
    }

    public void setUnreadMsg(int unreadMsg) {
        this.unreadMsg = unreadMsg;
        for (Observer<Integer> o : observers
        ) {
            o.update(TYPE_MSG, unreadMsg);
        }
    }

    public int getUnreadReport() {
        return unreadReport;
    }

    public void setUnreadReport(int unreadReport) {
        this.unreadReport = unreadReport;
        for (Observer<Integer> o : observers
        ) {
            o.update(TYPE_REPORT, unreadReport);
        }
    }

    public void setUnreadSys(int unreadSys) {
        this.unreadSys = unreadSys;
        for (Observer<Integer> o : observers
        ) {
            o.update(TYPE_SYS, unreadSys);
        }
    }

    public int getUnreadSys(){
        return unreadSys;
    }

    public void setUnreadTask(int unreadTask) {
        this.unreadTask = unreadTask;
        for (Observer<Integer> o : observers
        ) {
            o.update(TYPE_TASK, unreadTask);
        }
    }

    public int getUnreadTask(){
        return unreadTask;
    }

}
